package de.haw.shc.JSONObjects;

import android.util.Log;
import de.haw.shc.Interfaces.DeviceProperty.iBlind;
import de.haw.shc.Action.Actions;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: mizus
 * Date: 08.05.13
 * Time: 15:22
 * To change this template use File | Settings | File Templates.
 */
public class Blinds implements iBlind
{

    private String id, name, viewName, viewRaumName, raum;
    private String actionBlindsALL = "blinds_";

    public Blinds(){
    }


    @Override
    public JSONObject createAllBlindsOpen(){
        Map<String, String>  valMap = createValMap(actionBlindsALL+"open");
        JSONObject jsonObject = new JSONObject(valMap);
        Log.d("blindOpen_ALL", jsonObject.toString());
        return jsonObject;
    }

    @Override
    public JSONObject createAllBlindsClose(){
        Map<String, String>  valMap = createValMap(actionBlindsALL+"close");
        JSONObject jsonObject = new JSONObject(valMap);
        Log.d("blindClose_ALL", jsonObject.toString());
        return jsonObject;
    }


    @Override
    public JSONObject createOpenBlinds(){
        Map<String, String>  valMap = createValMap(name+"open");
        JSONObject jsonObject = new JSONObject(valMap);
        Log.d("blindOpen", jsonObject.toString());
        return jsonObject;
    }

    @Override
    public JSONObject createCloseBlinds(){
        Map<String, String> valMap = createValMap(name+"close");
        JSONObject jsonObject = new JSONObject(valMap);
        Log.d("BlindClose", jsonObject.toString());
        return jsonObject;
    }

    @Override
    public JSONObject createhalfOpenBlinds(){
        Map<String, String> valMap = createValMap(name+ "half");
        JSONObject jsonObject = new JSONObject(valMap);
        Log.d("BlindClose", jsonObject.toString());
        return jsonObject;
    }


    private Map<String, String> createValMap(String blind){
        Map<String, String> valMap = new HashMap<String, String>();
        valMap.put("action", blind);
        valMap.put("Id", "Timo_Stephan");
        valMap.put("Version", null);

        return valMap;
    }


    @Override
    public String getName() {
        return name;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public String getID() {
        return id;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void setRaum(String aRaum) {
       raum = aRaum; //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public String getRaum() {
        return raum;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    @Override
    public void setID(String ID) {
        id = ID;//To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean isColorPicker() {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void setColorable(boolean bool) {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void setViewName(String name) {
       viewName = name; //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public String getViewName() {
        return viewName;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void setViewRaumName(String name) {
        viewRaumName = name;//To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public String getViewRaumName() {
        return viewRaumName;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean isWindow() {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean isBlind() {
        return true;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean isLight() {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean isRadiator() {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean isCurtain() {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public JSONObject deactivate() {
        return this.createAllBlindsClose();  //To change body of implemented methods use File | Settings | File Templates.
    }

    public JSONObject activate(){
        return this.createOpenBlinds();
    }

    @Override
    public String getDeviceControll() {
        return Actions.BLINDCONTROL;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public String toString(){
        return "Name: " + getViewName() + " Room: "+ getViewRaumName();
    }



}
